﻿/*
 * Created by SharpDevelop.
 * User: Christian
 * Date: 20.02.2011
 * Time: 11:01
 * 
 * To change this template use Tools | Options | Coding | Edit Standard Headers.
 */
using System;
using System.Collections.Generic;
using ThatsMeSDK;

namespace SDKTest
{
	/// <summary>
	/// Description of KernelTestFuncsND.
	/// </summary>
	public class KernelTestFuncsND
	{
		public KernelTestFuncsND()
		{
            RunTests();
		}

        private void RunTests()
        {
            User me = TestAuthentificate();
            TestProperties(me);
            Member member = new Member("tmdotnetapi");
            TestMemberPropertys(member);
            TestSendMessage(me.Token);
        }
        
        private void TestSendMessage(string token)
        {
        	ThatsMeSDK.Core.ServiceHandler.SendMessage(token,"test\nnew line","intheair","new line test");
        	Console.WriteLine("message sent");
        }
        
        private void TestProfileDescription()
        {
        	Member m = ThatsMeSDK.Core.ServiceHandler.GetMemberByNick("tmdotnetapi");
        	Console.WriteLine("Profiltext:\n\n"+m.Description);
        	
        }

	    private User TestAuthentificate()	
		{
				IUser testMember = new User("tmdotnetapi","nexpose");
				
				if(testMember.Token == null)
				{
					Console.WriteLine("authentification failed!");
					return null;
				}
				else
				{
					Console.WriteLine("Token: " +  testMember.Token);
				}
				
				return (User)testMember;
		}

        private bool TestProperties(User me)
        {
            Console.WriteLine("Property Tests startet!");
            List<GalleryCategory> myCategories = me.Categories;
            List<GalleryPicture> myPictures = me.Gallery;
            Console.WriteLine("Kanton: "+me.Canton);
            Console.WriteLine("Birthday: "+ me.Birthday);
            Console.WriteLine("Gender: "+ me.Sex);
            int myUnreadMailsCount = me.UserMailBox.MailsCount.Unread.Total;
			if(myUnreadMailsCount > 0 )
				Console.WriteLine("You have "+myUnreadMailsCount.ToString()+" new Messages");
			else
				Console.WriteLine("You have zero new Messages    count: "+myUnreadMailsCount.ToString());
            Console.WriteLine("Property Tests passed!");
            return true;
        }
        
        private bool TestMemberPropertys(Member member)
        {
        	Console.WriteLine("Property Member Tests startet!");
        	Console.WriteLine("Kanton: "+member.Canton);
        	Console.WriteLine("Property Member Tests passed!");
        	return true;
        }

	}
}
			

